package com.buaa.pm.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.buaa.pm.entity.*;
import com.buaa.pm.enumeration.ExtractionStatus;
import com.buaa.pm.feign.ExtractClient;
import com.buaa.pm.model.ResultModel;
import com.buaa.pm.model.dto.ParamRequestDTO;
import com.buaa.pm.model.dto.ProjectInfoDTO;
import com.buaa.pm.model.dto.TaskInfoDTO;
import com.buaa.pm.service.ExtractRecordService;
import com.buaa.pm.service.ExtractResultService;
import com.buaa.pm.service.ParagraphService;
import com.buaa.pm.service.TaskService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/task")
public class TaskController {
    @Autowired
    private TaskService taskService;

    @PostMapping("/create")
    public ResultModel<Task> createTask(@RequestBody TaskInfoDTO taskInfoDTO){
        return ResultModel.success(taskService.createTask(taskInfoDTO));
    }

    @GetMapping("/list-by-project")
    public ResultModel<List<Task>> listByProject(@RequestParam String projectId) {
        return ResultModel.success(taskService.listTaskByProject(projectId));
    }

    @GetMapping("/get-task-by-id")
    public ResultModel<Task> getTaskById(@RequestParam String taskId) {
        return ResultModel.success(taskService.getTaskById(taskId));
    }

}
